﻿CREATE PROCEDURE admin.s_Make_UserNameDefault
	@Drop bit
AS
IF @Drop = 1 ALTER TABLE t_Payment DROP CONSTRAINT DF_t_Payment_StatusUser
ELSE ALTER TABLE t_Payment ADD CONSTRAINT DF_t_Payment_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_BuyBack DROP CONSTRAINT DF_t_BuyBack_StatusUser
ELSE ALTER TABLE t_BuyBack ADD CONSTRAINT DF_t_BuyBack_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_PurchaseBatch DROP CONSTRAINT DF_t_PurchaseBatch_StatusUser
ELSE ALTER TABLE t_PurchaseBatch ADD CONSTRAINT DF_t_PurchaseBatch_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_ObjectStatus DROP CONSTRAINT DF_t_ObjectStatus_UserName
ELSE ALTER TABLE t_ObjectStatus ADD CONSTRAINT DF_t_ObjectStatus_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

IF @Drop = 1 ALTER TABLE thist_Root DROP CONSTRAINT DF_thist_Root_UserName
ELSE ALTER TABLE thist_Root ADD CONSTRAINT DF_thist_Root_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

IF @Drop = 1 ALTER TABLE t_TrackerLicensesHistory DROP CONSTRAINT DF_t_TrackerLicensesHistory_Who
ELSE ALTER TABLE t_TrackerLicensesHistory ADD CONSTRAINT DF_t_TrackerLicensesHistory_Who DEFAULT ([dbo].[UserName]()) FOR Who

IF @Drop = 1 ALTER TABLE t_VerificationSmart DROP CONSTRAINT DF_t_VerificationSmart_StatusUser
ELSE ALTER TABLE t_VerificationSmart ADD CONSTRAINT DF_t_VerificationSmart_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_Note DROP CONSTRAINT DF_t_Note_StatusUser
ELSE ALTER TABLE t_Note ADD CONSTRAINT DF_t_Note_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_Loan DROP CONSTRAINT DF_t_Loan_StatusUser
ELSE ALTER TABLE t_Loan ADD CONSTRAINT DF_t_Loan_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_Collection DROP CONSTRAINT DF_t_Collection_StatusUser
ELSE ALTER TABLE t_Collection ADD CONSTRAINT DF_t_Collection_StatusUser DEFAULT ([dbo].[UserName]()) FOR StatusUser

IF @Drop = 1 ALTER TABLE t_Loan_Menus DROP CONSTRAINT DF_t_Applicant_Menus_UserName
ELSE ALTER TABLE t_Loan_Menus ADD CONSTRAINT DF_t_Applicant_Menus_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

IF @Drop = 1 ALTER TABLE t_Note DROP CONSTRAINT DF_t_Note_NoteUser
ELSE ALTER TABLE t_Note ADD CONSTRAINT DF_t_Note_NoteUser DEFAULT ([dbo].[UserName]()) FOR NoteUser

IF @Drop = 1 ALTER TABLE tlog_State DROP CONSTRAINT DF_tlog_Status_UserName
ELSE ALTER TABLE tlog_State ADD CONSTRAINT DF_tlog_Status_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

IF @Drop = 1 ALTER TABLE t_IncompleteList DROP CONSTRAINT DF_t_IncompleteList_UserName
ELSE ALTER TABLE t_IncompleteList ADD CONSTRAINT DF_t_IncompleteList_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

IF @Drop = 1 ALTER TABLE t_TrackerRequestNotes DROP CONSTRAINT DF_t_TrackerRequestNotes_UserName
ELSE ALTER TABLE t_TrackerRequestNotes ADD CONSTRAINT DF_t_TrackerRequestNotes_UserName DEFAULT ([dbo].[UserName]()) FOR UserName

